home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 November / PCWNOV08.iso / Software / Freeware / Adobe Media Player 1.1 / adobe_media_player.air / AMP.swf / scripts / mx / controls / ComboBox.as < prev    next >
Encoding:
Text File  |  2008-07-17  |  31.5 KB  |  1,031 lines

  1. package mx.controls
  2. {
  3.    import flash.events.Event;
  4.    import flash.events.FocusEvent;
  5.    import flash.events.KeyboardEvent;
  6.    import flash.events.MouseEvent;
  7.    import flash.geom.Point;
  8.    import flash.geom.Rectangle;
  9.    import flash.text.TextLineMetrics;
  10.    import flash.ui.Keyboard;
  11.    import mx.collections.ArrayCollection;
  12.    import mx.collections.CursorBookmark;
  13.    import mx.controls.dataGridClasses.DataGridListData;
  14.    import mx.controls.listClasses.BaseListData;
  15.    import mx.controls.listClasses.IDropInListItemRenderer;
  16.    import mx.controls.listClasses.IListItemRenderer;
  17.    import mx.controls.listClasses.ListBase;
  18.    import mx.controls.listClasses.ListData;
  19.    import mx.core.ClassFactory;
  20.    import mx.core.EdgeMetrics;
  21.    import mx.core.FlexVersion;
  22.    import mx.core.IDataRenderer;
  23.    import mx.core.IFactory;
  24.    import mx.core.ScrollPolicy;
  25.    import mx.core.UIComponent;
  26.    import mx.core.UIComponentGlobals;
  27.    import mx.core.mx_internal;
  28.    import mx.effects.Tween;
  29.    import mx.events.CollectionEvent;
  30.    import mx.events.CollectionEventKind;
  31.    import mx.events.DropdownEvent;
  32.    import mx.events.FlexEvent;
  33.    import mx.events.FlexMouseEvent;
  34.    import mx.events.ListEvent;
  35.    import mx.events.ScrollEvent;
  36.    import mx.events.ScrollEventDetail;
  37.    import mx.managers.PopUpManager;
  38.    import mx.styles.CSSStyleDeclaration;
  39.    import mx.styles.StyleManager;
  40.    
  41.    use namespace mx_internal;
  42.    
  43.    public class ComboBox extends ComboBase implements IDataRenderer, IDropInListItemRenderer, IListItemRenderer
  44.    {
  45.       mx_internal static var createAccessibilityImplementation:Function;
  46.       
  47.       mx_internal static const VERSION:String = "3.0.0.0";
  48.       
  49.       private var _labelField:String = "label";
  50.       
  51.       private var dropdownBorderStyle:String = "solid";
  52.       
  53.       private var implicitSelectedIndex:Boolean = false;
  54.       
  55.       private var _selectedIndexOnDropdown:int = -1;
  56.       
  57.       private var preferredDropdownWidth:Number;
  58.       
  59.       private var collectionChanged:Boolean = false;
  60.       
  61.       private var labelFunctionChanged:Boolean;
  62.       
  63.       private var selectedItemSet:Boolean;
  64.       
  65.       private var _dropdownWidth:Number = 100;
  66.       
  67.       private var inTween:Boolean = false;
  68.       
  69.       private var _oldIndex:int;
  70.       
  71.       private var tweenUp:Boolean = false;
  72.       
  73.       private var tween:Tween = null;
  74.       
  75.       private var labelFieldChanged:Boolean;
  76.       
  77.       private var _dropdown:ListBase;
  78.       
  79.       private var _dropdownFactory:IFactory;
  80.       
  81.       private var explicitText:Boolean;
  82.       
  83.       private var _prompt:String;
  84.       
  85.       private var _data:Object;
  86.       
  87.       private var bInKeyDown:Boolean = false;
  88.       
  89.       private var promptChanged:Boolean = false;
  90.       
  91.       private var _rowCount:int = 5;
  92.       
  93.       private var bRemoveDropdown:Boolean = false;
  94.       
  95.       private var _showingDropdown:Boolean = false;
  96.       
  97.       private var triggerEvent:Event;
  98.       
  99.       private var _listData:BaseListData;
  100.       
  101.       private var _itemRenderer:IFactory;
  102.       
  103.       private var _labelFunction:Function;
  104.       
  105.       public function ComboBox()
  106.       {
  107.          _dropdownFactory = new ClassFactory(List);
  108.          super();
  109.          dataProvider = new ArrayCollection();
  110.          mx_internal::useFullDropdownSkin = true;
  111.          mx_internal::wrapDownArrowButton = false;
  112.          addEventListener("unload",unloadHandler);
  113.          addEventListener(Event.REMOVED_FROM_STAGE,removedFromStageHandler);
  114.       }
  115.       
  116.       override protected function calculatePreferredSizeFromData(param1:int) : Object
  117.       {
  118.          var _loc6_:TextLineMetrics = null;
  119.          var _loc8_:Object = null;
  120.          var _loc9_:String = null;
  121.          var _loc2_:Number = 0;
  122.          var _loc3_:Number = 0;
  123.          var _loc4_:CursorBookmark = !!iterator ? iterator.bookmark : null;
  124.          iterator.seek(CursorBookmark.FIRST,0);
  125.          var _loc5_:* = iterator != null;
  126.          var _loc7_:int = 0;
  127.          while(_loc7_ < param1)
  128.          {
  129.             if(_loc5_)
  130.             {
  131.                _loc8_ = !!iterator ? iterator.current : null;
  132.             }
  133.             else
  134.             {
  135.                _loc8_ = null;
  136.             }
  137.             _loc9_ = itemToLabel(_loc8_);
  138.             _loc6_ = measureText(_loc9_);
  139.             _loc2_ = Math.max(_loc2_,_loc6_.width);
  140.             _loc3_ = Math.max(_loc3_,_loc6_.height);
  141.             if(iterator)
  142.             {
  143.                iterator.moveNext();
  144.             }
  145.             _loc7_++;
  146.          }
  147.          if(prompt)
  148.          {
  149.             _loc6_ = measureText(prompt);
  150.             _loc2_ = Math.max(_loc2_,_loc6_.width);
  151.             _loc3_ = Math.max(_loc3_,_loc6_.height);
  152.          }
  153.          _loc2_ += getStyle("paddingLeft") + getStyle("paddingRight");
  154.          if(iterator)
  155.          {
  156.             iterator.seek(_loc4_,0);
  157.          }
  158.          return {
  159.             "width":_loc2_,
  160.             "height":_loc3_
  161.          };
  162.       }
  163.       
  164.       private function dropdown_scrollHandler(param1:Event) : void
  165.       {
  166.          var _loc2_:ScrollEvent = null;
  167.          if(param1 is ScrollEvent)
  168.          {
  169.             _loc2_ = ScrollEvent(param1);
  170.             if(_loc2_.detail == ScrollEventDetail.THUMB_TRACK || _loc2_.detail == ScrollEventDetail.THUMB_POSITION || _loc2_.detail == ScrollEventDetail.LINE_UP || _loc2_.detail == ScrollEventDetail.LINE_DOWN)
  171.             {
  172.                dispatchEvent(_loc2_);
  173.             }
  174.          }
  175.       }
  176.       
  177.       public function get dropdown() : ListBase
  178.       {
  179.          return getDropdown();
  180.       }
  181.       
  182.       public function get selectedLabel() : String
  183.       {
  184.          var _loc1_:Object = selectedItem;
  185.          return itemToLabel(_loc1_);
  186.       }
  187.       
  188.       override protected function focusOutHandler(param1:FocusEvent) : void
  189.       {
  190.          if(_showingDropdown && Boolean(_dropdown))
  191.          {
  192.             if(!param1.relatedObject || !_dropdown.contains(param1.relatedObject))
  193.             {
  194.                close();
  195.             }
  196.          }
  197.          super.focusOutHandler(param1);
  198.       }
  199.       
  200.       private function popup_moveHandler(param1:Event) : void
  201.       {
  202.          destroyDropdown();
  203.       }
  204.       
  205.       private function destroyDropdown() : void
  206.       {
  207.          if(Boolean(_dropdown) && !_showingDropdown)
  208.          {
  209.             if(inTween)
  210.             {
  211.                tween.endTween();
  212.             }
  213.             else
  214.             {
  215.                PopUpManager.removePopUp(_dropdown);
  216.                _dropdown = null;
  217.             }
  218.          }
  219.       }
  220.       
  221.       [Bindable("dropdownWidthChanged")]
  222.       public function get dropdownWidth() : Number
  223.       {
  224.          return _dropdownWidth;
  225.       }
  226.       
  227.       private function unloadHandler(param1:Event) : void
  228.       {
  229.          if(inTween)
  230.          {
  231.             UIComponent.resumeBackgroundProcessing();
  232.             inTween = false;
  233.          }
  234.          if(_dropdown)
  235.          {
  236.             _dropdown.parent.removeChild(_dropdown);
  237.          }
  238.       }
  239.       
  240.       public function open() : void
  241.       {
  242.          displayDropdown(true);
  243.       }
  244.       
  245.       public function set data(param1:Object) : void
  246.       {
  247.          var _loc2_:* = undefined;
  248.          _data = param1;
  249.          if(Boolean(_listData) && _listData is DataGridListData)
  250.          {
  251.             _loc2_ = _data[DataGridListData(_listData).dataField];
  252.          }
  253.          else if(_listData is ListData && ListData(_listData).labelField in _data)
  254.          {
  255.             _loc2_ = _data[ListData(_listData).labelField];
  256.          }
  257.          else
  258.          {
  259.             _loc2_ = _data;
  260.          }
  261.          if(_loc2_ !== undefined && !selectedItemSet)
  262.          {
  263.             selectedItem = _loc2_;
  264.             selectedItemSet = false;
  265.          }
  266.          dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
  267.       }
  268.       
  269.       [Bindable("resize")]
  270.       public function get rowCount() : int
  271.       {
  272.          return Math.max(1,Math.min(collection.length,_rowCount));
  273.       }
  274.       
  275.       override protected function textInput_changeHandler(param1:Event) : void
  276.       {
  277.          super.textInput_changeHandler(param1);
  278.          dispatchChangeEvent(param1,-1,-2);
  279.       }
  280.       
  281.       private function dropdown_itemRollOutHandler(param1:Event) : void
  282.       {
  283.          dispatchEvent(param1);
  284.       }
  285.       
  286.       override protected function measure() : void
  287.       {
  288.          super.measure();
  289.          measuredMinWidth = Math.max(measuredWidth,DEFAULT_MEASURED_MIN_WIDTH);
  290.          var _loc1_:Number = measureText("M").height + 6;
  291.          var _loc2_:EdgeMetrics = borderMetrics;
  292.          measuredMinHeight = measuredHeight = Math.max(_loc1_ + _loc2_.top + _loc2_.bottom,DEFAULT_MEASURED_MIN_HEIGHT);
  293.          if(FlexVersion.compatibilityVersion >= FlexVersion.VERSION_3_0)
  294.          {
  295.             measuredMinHeight = measuredHeight = measuredHeight + (getStyle("paddingTop") + getStyle("paddingBottom"));
  296.          }
  297.       }
  298.       
  299.       private function dropdown_itemRollOverHandler(param1:Event) : void
  300.       {
  301.          dispatchEvent(param1);
  302.       }
  303.       
  304.       public function get prompt() : String
  305.       {
  306.          return _prompt;
  307.       }
  308.       
  309.       override protected function keyDownHandler(param1:KeyboardEvent) : void
  310.       {
  311.          var _loc2_:int = 0;
  312.          if(param1.target == textInput)
  313.          {
  314.             return;
  315.          }
  316.          if(param1.ctrlKey && param1.keyCode == Keyboard.DOWN)
  317.          {
  318.             displayDropdown(true,param1);
  319.             param1.stopPropagation();
  320.          }
  321.          else if(param1.ctrlKey && param1.keyCode == Keyboard.UP)
  322.          {
  323.             close(param1);
  324.             param1.stopPropagation();
  325.          }
  326.          else if(param1.keyCode == Keyboard.ESCAPE)
  327.          {
  328.             if(_showingDropdown)
  329.             {
  330.                if(_oldIndex != _dropdown.selectedIndex)
  331.                {
  332.                   selectedIndex = _oldIndex;
  333.                }
  334.                displayDropdown(false);
  335.                param1.stopPropagation();
  336.             }
  337.          }
  338.          else if(param1.keyCode == Keyboard.ENTER)
  339.          {
  340.             if(_showingDropdown)
  341.             {
  342.                close();
  343.                param1.stopPropagation();
  344.             }
  345.          }
  346.          else if(!editable || param1.keyCode == Keyboard.UP || param1.keyCode == Keyboard.DOWN || param1.keyCode == Keyboard.PAGE_UP || param1.keyCode == Keyboard.PAGE_DOWN)
  347.          {
  348.             _loc2_ = selectedIndex;
  349.             bInKeyDown = _showingDropdown;
  350.             dropdown.dispatchEvent(param1.clone());
  351.             param1.stopPropagation();
  352.             bInKeyDown = false;
  353.          }
  354.       }
  355.       
  356.       public function set dropdownWidth(param1:Number) : void
  357.       {
  358.          _dropdownWidth = param1;
  359.          preferredDropdownWidth = param1;
  360.          if(_dropdown)
  361.          {
  362.             _dropdown.setActualSize(param1,_dropdown.height);
  363.          }
  364.          dispatchEvent(new Event("dropdownWidthChanged"));
  365.       }
  366.       
  367.       [Bindable("labelFieldChanged")]
  368.       public function get labelField() : String
  369.       {
  370.          return _labelField;
  371.       }
  372.       
  373.       public function set dropdownFactory(param1:IFactory) : void
  374.       {
  375.          _dropdownFactory = param1;
  376.          dispatchEvent(new Event("dropdownFactoryChanged"));
  377.       }
  378.       
  379.       [Bindable("collectionChange")]
  380.       override public function set dataProvider(param1:Object) : void
  381.       {
  382.          mx_internal::selectionChanged = true;
  383.          super.dataProvider = param1;
  384.          destroyDropdown();
  385.          _showingDropdown = false;
  386.          invalidateProperties();
  387.          invalidateSize();
  388.       }
  389.       
  390.       mx_internal function get isShowingDropdown() : Boolean
  391.       {
  392.          return _showingDropdown;
  393.       }
  394.       
  395.       override protected function collectionChangeHandler(param1:Event) : void
  396.       {
  397.          var _loc3_:CollectionEvent = null;
  398.          var _loc2_:int = selectedIndex;
  399.          super.collectionChangeHandler(param1);
  400.          if(param1 is CollectionEvent)
  401.          {
  402.             _loc3_ = CollectionEvent(param1);
  403.             if(collection.length == 0)
  404.             {
  405.                if(!mx_internal::selectedIndexChanged && !mx_internal::selectedItemChanged)
  406.                {
  407.                   super.selectedIndex = -1;
  408.                   implicitSelectedIndex = true;
  409.                   invalidateDisplayList();
  410.                }
  411.                if(Boolean(textInput) && !editable)
  412.                {
  413.                   textInput.text = "";
  414.                }
  415.             }
  416.             else if(_loc3_.kind == CollectionEventKind.ADD)
  417.             {
  418.                if(collection.length != _loc3_.items.length)
  419.                {
  420.                   return;
  421.                }
  422.                if(selectedIndex == -1 && _prompt == null)
  423.                {
  424.                   selectedIndex = 0;
  425.                }
  426.             }
  427.             else if(_loc3_.kind == CollectionEventKind.UPDATE)
  428.             {
  429.                if(_loc3_.location == selectedIndex || _loc3_.items[0].source == selectedItem)
  430.                {
  431.                   mx_internal::selectionChanged = true;
  432.                }
  433.             }
  434.             else
  435.             {
  436.                if(_loc3_.kind == CollectionEventKind.REPLACE)
  437.                {
  438.                   return;
  439.                }
  440.                if(_loc3_.kind == CollectionEventKind.RESET)
  441.                {
  442.                   collectionChanged = true;
  443.                   if(!mx_internal::selectedIndexChanged && !mx_internal::selectedItemChanged)
  444.                   {
  445.                      selectedIndex = !!prompt ? -1 : 0;
  446.                   }
  447.                   invalidateProperties();
  448.                }
  449.             }
  450.             invalidateDisplayList();
  451.             destroyDropdown();
  452.             _showingDropdown = false;
  453.          }
  454.       }
  455.       
  456.       private function dropdown_mouseDownOutsideHandler(param1:MouseEvent) : void
  457.       {
  458.          if(param1.target != _dropdown)
  459.          {
  460.             return;
  461.          }
  462.          if(!hitTestPoint(param1.stageX,param1.stageY,true))
  463.          {
  464.             close(param1);
  465.          }
  466.       }
  467.       
  468.       [Bindable("dataChange")]
  469.       public function get listData() : BaseListData
  470.       {
  471.          return _listData;
  472.       }
  473.       
  474.       private function getDropdown() : ListBase
  475.       {
  476.          var _loc1_:String = null;
  477.          var _loc2_:CSSStyleDeclaration = null;
  478.          if(!initialized)
  479.          {
  480.             return null;
  481.          }
  482.          if(!mx_internal::hasDropdown())
  483.          {
  484.             _loc1_ = getStyle("dropDownStyleName");
  485.             if(_loc1_ == null)
  486.             {
  487.                _loc1_ = getStyle("dropdownStyleName");
  488.             }
  489.             _dropdown = dropdownFactory.newInstance();
  490.             _dropdown.visible = false;
  491.             _dropdown.focusEnabled = false;
  492.             _dropdown.owner = this;
  493.             if(itemRenderer)
  494.             {
  495.                _dropdown.itemRenderer = itemRenderer;
  496.             }
  497.             if(FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0)
  498.             {
  499.                _dropdown.styleName = this;
  500.             }
  501.             if(_loc1_)
  502.             {
  503.                if(FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0)
  504.                {
  505.                   _loc2_ = StyleManager.getStyleDeclaration("." + _loc1_);
  506.                   if(_loc2_)
  507.                   {
  508.                      _dropdown.styleDeclaration = _loc2_;
  509.                   }
  510.                }
  511.                else
  512.                {
  513.                   _dropdown.styleName = _loc1_;
  514.                }
  515.             }
  516.             else if(FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0)
  517.             {
  518.                _dropdown.setStyle("cornerRadius",0);
  519.             }
  520.             PopUpManager.addPopUp(_dropdown,this);
  521.             _dropdown.setStyle("selectionDuration",0);
  522.             if(FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0 && dropdownBorderStyle && dropdownBorderStyle != "")
  523.             {
  524.                _dropdown.setStyle("borderStyle",dropdownBorderStyle);
  525.             }
  526.             if(!dataProvider)
  527.             {
  528.                dataProvider = new ArrayCollection();
  529.             }
  530.             _dropdown.dataProvider = dataProvider;
  531.             _dropdown.rowCount = rowCount;
  532.             _dropdown.width = _dropdownWidth;
  533.             _dropdown.selectedIndex = selectedIndex;
  534.             _oldIndex = selectedIndex;
  535.             _dropdown.verticalScrollPolicy = ScrollPolicy.AUTO;
  536.             _dropdown.labelField = _labelField;
  537.             _dropdown.labelFunction = _labelFunction;
  538.             _dropdown.allowDragSelection = true;
  539.             _dropdown.addEventListener("change",dropdown_changeHandler);
  540.             _dropdown.addEventListener(ScrollEvent.SCROLL,dropdown_scrollHandler);
  541.             _dropdown.addEventListener(ListEvent.ITEM_ROLL_OVER,dropdown_itemRollOverHandler);
  542.             _dropdown.addEventListener(ListEvent.ITEM_ROLL_OUT,dropdown_itemRollOutHandler);
  543.             _dropdown.addEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE,dropdown_mouseDownOutsideHandler);
  544.             _dropdown.addEventListener(FlexMouseEvent.MOUSE_WHEEL_OUTSIDE,dropdown_mouseWheelOutsideHandler);
  545.             _dropdown.addEventListener(ListEvent.ITEM_CLICK,dropdown_itemClickHandler);
  546.             UIComponentGlobals.mx_internal::layoutManager.validateClient(_dropdown,true);
  547.             _dropdown.setActualSize(_dropdownWidth,_dropdown.getExplicitOrMeasuredHeight());
  548.             _dropdown.validateDisplayList();
  549.             _dropdown.cacheAsBitmap = true;
  550.             systemManager.addEventListener(Event.RESIZE,stage_resizeHandler,false,0,true);
  551.          }
  552.          _dropdown.scaleX = scaleX;
  553.          _dropdown.scaleY = scaleY;
  554.          return _dropdown;
  555.       }
  556.       
  557.       private function stage_resizeHandler(param1:Event) : void
  558.       {
  559.          if(_dropdown)
  560.          {
  561.             _dropdown.mx_internal::$visible = false;
  562.             _showingDropdown = false;
  563.          }
  564.       }
  565.       
  566.       override protected function downArrowButton_buttonDownHandler(param1:FlexEvent) : void
  567.       {
  568.          if(_showingDropdown)
  569.          {
  570.             close(param1);
  571.          }
  572.          else
  573.          {
  574.             displayDropdown(true,param1);
  575.          }
  576.       }
  577.       
  578.       mx_internal function onTweenEnd(param1:Number) : void
  579.       {
  580.          if(_dropdown)
  581.          {
  582.             _dropdown.scrollRect = null;
  583.             inTween = false;
  584.             _dropdown.enabled = true;
  585.             _dropdown.visible = _showingDropdown;
  586.          }
  587.          if(bRemoveDropdown)
  588.          {
  589.             PopUpManager.removePopUp(_dropdown);
  590.             _dropdown = null;
  591.             bRemoveDropdown = false;
  592.          }
  593.          UIComponent.resumeBackgroundProcessing();
  594.          var _loc2_:DropdownEvent = new DropdownEvent(_showingDropdown ? DropdownEvent.OPEN : DropdownEvent.CLOSE);
  595.          _loc2_.triggerEvent = triggerEvent;
  596.          dispatchEvent(_loc2_);
  597.       }
  598.       
  599.       [Bindable("valueCommit")]
  600.       [Bindable("collectionChange")]
  601.       [Bindable("change")]
  602.       override public function set selectedItem(param1:Object) : void
  603.       {
  604.          selectedItemSet = true;
  605.          super.selectedItem = param1;
  606.       }
  607.       
  608.       override protected function initializeAccessibility() : void
  609.       {
  610.          if(ComboBox.mx_internal::createAccessibilityImplementation != null)
  611.          {
  612.             ComboBox.mx_internal::createAccessibilityImplementation(this);
  613.          }
  614.       }
  615.       
  616.       public function itemToLabel(param1:Object) : String
  617.       {
  618.          var item:Object = param1;
  619.          if(item == null)
  620.          {
  621.             return "";
  622.          }
  623.          if(labelFunction != null)
  624.          {
  625.             return labelFunction(item);
  626.          }
  627.          if(typeof item == "object")
  628.          {
  629.             try
  630.             {
  631.                if(item[labelField] != null)
  632.                {
  633.                   item = item[labelField];
  634.                }
  635.             }
  636.             catch(e:Error)
  637.             {
  638.             }
  639.          }
  640.          else if(typeof item == "xml")
  641.          {
  642.             try
  643.             {
  644.                if(item[labelField].length() != 0)
  645.                {
  646.                   item = item[labelField];
  647.                }
  648.             }
  649.             catch(e:Error)
  650.             {
  651.             }
  652.          }
  653.          if(typeof item == "string")
  654.          {
  655.             return String(item);
  656.          }
  657.          try
  658.          {
  659.             return item.toString();
  660.          }
  661.          catch(e:Error)
  662.          {
  663.          }
  664.          return " ";
  665.       }
  666.       
  667.       private function dropdown_mouseWheelOutsideHandler(param1:MouseEvent) : void
  668.       {
  669.          dropdown_mouseDownOutsideHandler(param1);
  670.       }
  671.       
  672.       [Bindable("dataChange")]
  673.       public function get data() : Object
  674.       {
  675.          return _data;
  676.       }
  677.       
  678.       mx_internal function onTweenUpdate(param1:Number) : void
  679.       {
  680.          if(_dropdown)
  681.          {
  682.             _dropdown.scrollRect = new Rectangle(0,param1,_dropdown.width,_dropdown.height);
  683.          }
  684.       }
  685.       
  686.       private function removedFromStageHandler(param1:Event) : void
  687.       {
  688.          destroyDropdown();
  689.       }
  690.       
  691.       [Bindable("dropdownFactoryChanged")]
  692.       public function get dropdownFactory() : IFactory
  693.       {
  694.          return _dropdownFactory;
  695.       }
  696.       
  697.       override public function styleChanged(param1:String) : void
  698.       {
  699.          destroyDropdown();
  700.          super.styleChanged(param1);
  701.       }
  702.       
  703.       public function set prompt(param1:String) : void
  704.       {
  705.          _prompt = param1;
  706.          promptChanged = true;
  707.          invalidateProperties();
  708.       }
  709.       
  710.       override protected function commitProperties() : void
  711.       {
  712.          explicitText = mx_internal::textChanged;
  713.          super.commitProperties();
  714.          if(collectionChanged)
  715.          {
  716.             if(selectedIndex == -1 && implicitSelectedIndex && _prompt == null)
  717.             {
  718.                selectedIndex = 0;
  719.             }
  720.             mx_internal::selectedIndexChanged = true;
  721.             collectionChanged = false;
  722.          }
  723.          if(promptChanged && prompt != null && selectedIndex == -1)
  724.          {
  725.             promptChanged = false;
  726.             textInput.text = prompt;
  727.          }
  728.       }
  729.       
  730.       mx_internal function hasDropdown() : Boolean
  731.       {
  732.          return _dropdown != null;
  733.       }
  734.       
  735.       public function set listData(param1:BaseListData) : void
  736.       {
  737.          _listData = param1;
  738.       }
  739.       
  740.       public function set labelField(param1:String) : void
  741.       {
  742.          _labelField = param1;
  743.          labelFieldChanged = true;
  744.          invalidateDisplayList();
  745.          dispatchEvent(new Event("labelFieldChanged"));
  746.       }
  747.       
  748.       public function set labelFunction(param1:Function) : void
  749.       {
  750.          _labelFunction = param1;
  751.          labelFunctionChanged = true;
  752.          invalidateDisplayList();
  753.          dispatchEvent(new Event("labelFunctionChanged"));
  754.       }
  755.       
  756.       protected function get dropDownStyleFilters() : Object
  757.       {
  758.          return null;
  759.       }
  760.       
  761.       public function set rowCount(param1:int) : void
  762.       {
  763.          _rowCount = param1;
  764.          if(_dropdown)
  765.          {
  766.             _dropdown.rowCount = param1;
  767.          }
  768.       }
  769.       
  770.       private function dropdown_changeHandler(param1:Event) : void
  771.       {
  772.          var _loc2_:int = selectedIndex;
  773.          if(_dropdown)
  774.          {
  775.             selectedIndex = _dropdown.selectedIndex;
  776.          }
  777.          if(!_showingDropdown)
  778.          {
  779.             dispatchChangeEvent(param1,_loc2_,selectedIndex);
  780.          }
  781.          else if(!bInKeyDown)
  782.          {
  783.             close();
  784.          }
  785.       }
  786.       
  787.       private function dropdown_itemClickHandler(param1:ListEvent) : void
  788.       {
  789.          if(_showingDropdown)
  790.          {
  791.             close();
  792.          }
  793.       }
  794.       
  795.       [Bindable("labelFunctionChanged")]
  796.       public function get labelFunction() : Function
  797.       {
  798.          return _labelFunction;
  799.       }
  800.       
  801.       [Bindable("valueCommit")]
  802.       [Bindable("collectionChange")]
  803.       [Bindable("change")]
  804.       override public function set selectedIndex(param1:int) : void
  805.       {
  806.          super.selectedIndex = param1;
  807.          if(param1 >= 0)
  808.          {
  809.             mx_internal::selectionChanged = true;
  810.          }
  811.          implicitSelectedIndex = false;
  812.          invalidateDisplayList();
  813.          if(textInput && !mx_internal::textChanged && param1 >= 0)
  814.          {
  815.             textInput.text = selectedLabel;
  816.          }
  817.          else if(Boolean(textInput) && Boolean(prompt))
  818.          {
  819.             textInput.text = prompt;
  820.          }
  821.       }
  822.       
  823.       private function dispatchChangeEvent(param1:Event, param2:int, param3:int) : void
  824.       {
  825.          var _loc4_:Event = null;
  826.          if(param2 != param3)
  827.          {
  828.             _loc4_ = param1 is ListEvent ? param1 : new ListEvent("change");
  829.             dispatchEvent(_loc4_);
  830.          }
  831.       }
  832.       
  833.       private function displayDropdown(param1:Boolean, param2:Event = null) : void
  834.       {
  835.          var _loc3_:Number = NaN;
  836.          var _loc4_:Number = NaN;
  837.          var _loc5_:Number = NaN;
  838.          var _loc6_:Function = null;
  839.          var _loc8_:int = 0;
  840.          var _loc9_:Number = NaN;
  841.          if(!initialized || param1 == _showingDropdown)
  842.          {
  843.             return;
  844.          }
  845.          var _loc7_:Point = new Point(0,unscaledHeight);
  846.          _loc7_ = localToGlobal(_loc7_);
  847.          if(param1)
  848.          {
  849.             _selectedIndexOnDropdown = selectedIndex;
  850.             getDropdown();
  851.             if(_dropdown.parent == null)
  852.             {
  853.                PopUpManager.addPopUp(_dropdown,this);
  854.             }
  855.             else
  856.             {
  857.                PopUpManager.bringToFront(_dropdown);
  858.             }
  859.             _loc7_ = _dropdown.parent.globalToLocal(_loc7_);
  860.             if(_loc7_.y + _dropdown.height > screen.height && _loc7_.y > _dropdown.height)
  861.             {
  862.                _loc7_.y -= unscaledHeight + _dropdown.height;
  863.                _loc3_ = -_dropdown.height;
  864.                tweenUp = true;
  865.             }
  866.             else
  867.             {
  868.                _loc3_ = _dropdown.height;
  869.                tweenUp = false;
  870.             }
  871.             _loc8_ = _dropdown.selectedIndex;
  872.             if(_loc8_ == -1)
  873.             {
  874.                _loc8_ = 0;
  875.             }
  876.             _loc9_ = _dropdown.verticalScrollPosition;
  877.             _loc9_ = _loc8_ - 1;
  878.             _loc9_ = Math.min(Math.max(_loc9_,0),_dropdown.maxVerticalScrollPosition);
  879.             _dropdown.verticalScrollPosition = _loc9_;
  880.             if(_dropdown.x != _loc7_.x || _dropdown.y != _loc7_.y)
  881.             {
  882.                _dropdown.move(_loc7_.x,_loc7_.y);
  883.             }
  884.             _dropdown.scrollRect = new Rectangle(0,_loc3_,_dropdown.width,_dropdown.height);
  885.             if(!_dropdown.visible)
  886.             {
  887.                _dropdown.visible = true;
  888.             }
  889.             bRemoveDropdown = false;
  890.             _showingDropdown = param1;
  891.             _loc5_ = getStyle("openDuration");
  892.             _loc4_ = 0;
  893.             _loc6_ = getStyle("openEasingFunction") as Function;
  894.          }
  895.          else if(_dropdown)
  896.          {
  897.             _loc7_ = _dropdown.parent.globalToLocal(_loc7_);
  898.             _loc4_ = _loc7_.y + _dropdown.height > screen.height || tweenUp ? -_dropdown.height : _dropdown.height;
  899.             _showingDropdown = param1;
  900.             _loc3_ = 0;
  901.             _loc5_ = getStyle("closeDuration");
  902.             _loc6_ = getStyle("closeEasingFunction") as Function;
  903.             _dropdown.mx_internal::resetDragScrolling();
  904.          }
  905.          inTween = true;
  906.          UIComponentGlobals.mx_internal::layoutManager.validateNow();
  907.          UIComponent.suspendBackgroundProcessing();
  908.          if(_dropdown)
  909.          {
  910.             _dropdown.enabled = false;
  911.          }
  912.          _loc5_ = Math.max(1,_loc5_);
  913.          tween = new Tween(this,_loc3_,_loc4_,_loc5_);
  914.          if(_loc6_ != null && Boolean(tween))
  915.          {
  916.             tween.easingFunction = _loc6_;
  917.          }
  918.          triggerEvent = param2;
  919.       }
  920.       
  921.       public function get itemRenderer() : IFactory
  922.       {
  923.          return _itemRenderer;
  924.       }
  925.       
  926.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  927.       {
  928.          super.updateDisplayList(param1,param2);
  929.          if(Boolean(_dropdown) && !inTween)
  930.          {
  931.             destroyDropdown();
  932.          }
  933.          else if(!_showingDropdown && inTween)
  934.          {
  935.             bRemoveDropdown = true;
  936.          }
  937.          var _loc3_:Number = preferredDropdownWidth;
  938.          if(isNaN(_loc3_))
  939.          {
  940.             _loc3_ = _dropdownWidth = param1;
  941.          }
  942.          if(labelFieldChanged)
  943.          {
  944.             if(_dropdown)
  945.             {
  946.                _dropdown.labelField = _labelField;
  947.             }
  948.             mx_internal::selectionChanged = true;
  949.             if(!explicitText)
  950.             {
  951.                textInput.text = selectedLabel;
  952.             }
  953.             labelFieldChanged = false;
  954.          }
  955.          if(labelFunctionChanged)
  956.          {
  957.             if(_dropdown)
  958.             {
  959.                _dropdown.labelFunction = _labelFunction;
  960.             }
  961.             mx_internal::selectionChanged = true;
  962.             if(!explicitText)
  963.             {
  964.                textInput.text = selectedLabel;
  965.             }
  966.             labelFunctionChanged = false;
  967.          }
  968.          if(mx_internal::selectionChanged)
  969.          {
  970.             if(!mx_internal::textChanged)
  971.             {
  972.                if(selectedIndex == -1 && Boolean(prompt))
  973.                {
  974.                   textInput.text = prompt;
  975.                }
  976.                else if(!explicitText)
  977.                {
  978.                   textInput.text = selectedLabel;
  979.                }
  980.             }
  981.             textInput.invalidateDisplayList();
  982.             textInput.validateNow();
  983.             if(editable)
  984.             {
  985.                textInput.mx_internal::getTextField().setSelection(0,textInput.text.length);
  986.                textInput.mx_internal::getTextField().scrollH = 0;
  987.             }
  988.             if(_dropdown)
  989.             {
  990.                _dropdown.selectedIndex = selectedIndex;
  991.             }
  992.             mx_internal::selectionChanged = false;
  993.          }
  994.          if(Boolean(_dropdown) && _dropdown.rowCount != rowCount)
  995.          {
  996.             _dropdown.rowCount = rowCount;
  997.          }
  998.       }
  999.       
  1000.       public function close(param1:Event = null) : void
  1001.       {
  1002.          if(_showingDropdown)
  1003.          {
  1004.             if(Boolean(_dropdown) && selectedIndex != _dropdown.selectedIndex)
  1005.             {
  1006.                selectedIndex = _dropdown.selectedIndex;
  1007.             }
  1008.             displayDropdown(false,param1);
  1009.             dispatchChangeEvent(new Event("dummy"),_selectedIndexOnDropdown,selectedIndex);
  1010.          }
  1011.       }
  1012.       
  1013.       public function set itemRenderer(param1:IFactory) : void
  1014.       {
  1015.          _itemRenderer = param1;
  1016.          if(_dropdown)
  1017.          {
  1018.             _dropdown.itemRenderer = param1;
  1019.          }
  1020.          invalidateSize();
  1021.          invalidateDisplayList();
  1022.          dispatchEvent(new Event("itemRendererChanged"));
  1023.       }
  1024.       
  1025.       override public function set showInAutomationHierarchy(param1:Boolean) : void
  1026.       {
  1027.       }
  1028.    }
  1029. }
  1030.  
  1031.